<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>健康干预
            <small>人群分类</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>健康干预</el-breadcrumb-item>
            <el-breadcrumb-item>人群分类</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="档案号/姓名" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="_findPage()" class="dalfBut">查询</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="fileNumber" label="档案号" align="center"></el-table-column>
                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                <el-table-column label="性别" align="center">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sex == null ? '人妖' : scope.row.sex == '1' ? '男' : scope.row.sex == '2' ? '女' : '人妖'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="age" label="年龄" align="center"></el-table-column>
                <el-table-column prop="healthprogramkeywordList" label="人群分类" align="center"></el-table-column>
                <el-table-column prop="healthManager" label="健康管理师" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">确认分类</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="确认分类" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form label-position="right" label-width="100px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="档案号:">
                                                <el-input v-html="formData.fileNumber"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="姓名:">
                                                <el-input v-html="formData.name"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="性别:">
                                                <el-input v-html="formData.sex"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="年龄:">
                                                <el-input v-html="formData.age"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="病例史">
                                                <el-input v-html="memberDies.medical" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="遗传史">
                                                <el-input v-html="memberDies.family" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="手术史">
                                                <el-input v-html="memberDies.previous" type="textarea"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>

                            <el-tab-pane label="体检信息" name="second">
                                <div class="">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>档案号</th>
                                            <th>体检日期</th>
                                            <th>体检套餐</th>
                                            <th>查看体检报告</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>
                                                <el-input v-html="medicalInformation.fileNumber"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <el-input v-html="medicalInformation.orderDate"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <el-input v-html="medicalInformation.setMealName"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <template>
                                                    <el-button type="text" @click="findStatus()">查看</el-button>
                                                </template>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </el-tab-pane>

                            <el-tab-pane label="评估结果" name="three">
                                <div class="">
                                    <table class="datatable">
                                        <thead>
                                        <tr>
                                            <th>档案号</th>
                                            <th>风险评估日期</th>
                                            <th>问卷状态</th>
                                            <th>查看评估报告</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>
                                                <el-input v-html="medicalInformation.fileNumber"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <el-input v-html="medicalInformation.orderDate"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <el-input v-html="medicalInformation.setMealName"
                                                          type="textarea"></el-input>
                                            </td>
                                            <td>
                                                <template>
                                                    <el-button type="text" @click="findStatus()">查看</el-button>
                                                </template>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </el-tab-pane>

                            <el-tab-pane label="确认分类" name="four">
                                <div class="checkScrol">
                                    <el-container>
                                        <el-aside width="100px"><font size="4">确认分类:</font></el-aside>
                                        <el-main>
                                            <table class="datatable">
                                                <tbody>
                                                <tr v-for="c in tableData">
                                                    <td>
                                                        <input :id="c.id" v-model="healthProgramIds" type="checkbox"
                                                               :value="c.id">
                                                    </td>
                                                    <td><label :for="c.id">{{c.keyword}}</label></td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </el-main>
                                    </el-container>
                                    <el-container>
                                        <el-header></el-header>
                                        <el-container>
                                            <el-aside width="100px">健康管理师</el-aside>
                                            <el-main>
                                                <select v-model="value">
                                                    <option v-for="c in userList">{{c.username}}</option>
                                                </select>
                                            </el-main>
                                        </el-container>
                                    </el-container>
                                </div>
                            </el-tab-pane>

                        </el-tabs>
                    </template>

                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleEdit()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',

        data: {
            activeName: 'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 100,
                queryString: null,
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            memberDies: {},//基本信息:病史遗传史,手术史
            medicalInformation: {},//体检信息
            value: null,//健康管理师回显值
            userList: [],//健康管理师下拉表数据
            tableData: [],//编辑表单中对应的列表数据
            healthProgramIds: [],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible4Edit: false,//控制编辑窗口显示/隐藏
            rules: {//校验规则
                code: [{required: true, message: '项目编码为必填项', trigger: 'blur'}],
                name: [{required: true, message: '项目名称为必填项', trigger: 'blur'}]
            },
        },
        created() {
            this.findPage();
        },
        methods: {
            //权限不足提示
            showMessage(r) {
            },
            //编辑
            handleEdit() {
                var param = {
                    fileNumber: this.formData.fileNumber,
                    value: this.value
                };
                axios.post("/member/healthEdit.do?healthProgramIds=" + this.healthProgramIds, param).then((res) => {
                    if (res.data.flag) {
                        this.dialogFormVisible4Edit = false;
                        this.$message({
                            message: res.data.message,
                            type: 'success',
                        })
                    } else {
                        this.$message.error(res.data.message)
                    }
                }).finally(() => {
                    this.findPage();
                });
            },

            _findPage() {
                this.pagination.currentPage = 1;
                this.findPage();
            },
            //分页查询
            findPage() {
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString,
                };
                axios.post("/member/findPageMMM.do", param).then((res) => {
                    if (res.data.flag) {
                        this.dataList = res.data.data.rows;
                        this.pagination.total = res.data.data.total;

                    } else {
                        this.$message.error(res.data.message)
                    }
                })
            },
            // 查询体检报告
            findStatus() {
                this.$alert(this.medicalInformation.orderStatus, '体检报告', {
                    confirmButtonText: '确定',
                    /*callback: action => {
                        this.$message({
                            type: 'info',
                            message: `action: ${ action }`
                        });
                    }*/
                });
            },
            // 弹出编辑窗口
            handleUpdate(row) {
                this.dialogFormVisible4Edit = true;
                this.activeName = 'first';
                //查询member表
                axios.post("/member/findOne.do?id=" + row.id).then((res) => {
                    if (res.data.flag) {
                        this.formData = res.data.data;
                        this.memberDies = this.formData.memberDies;
                    } else {
                        this.$message.error(res.data.message)
                    }
                });
                //体检信息
                axios.post("/member/findMedicalInformation.do?id=" + row.id).then((res) => {
                    if (res.data.flag) {
                        this.medicalInformation = res.data.data;
                    } else {
                        this.$message.error(res.data.message)
                    }
                });

                //确认分类
                axios.post("/healthProgram/findAllHealthProgramKeywordList.do").then((res) => {
                    if (res.data.flag) {
                        this.tableData = res.data.data;
                        axios.post("/member/findHealthProgramIds.do?id=" + row.id).then((res) => {
                            if (res.data.flag) {
                                this.healthProgramIds = res.data.data;
                            } else {
                                this.$message.error("获取失败")
                            }
                        });
                    } else {
                        this.$message.error(res.data.message)
                    }
                });
                axios.post("/user/findAllUser.do").then((res) => {
                    if (res.data.flag) {
                        this.userList = res.data.data;
                    } else {
                        this.$message.error(res.data.message)
                    }
                });
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {
                this.$confirm('此操作将永久删除该档案, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.post("/member/deletePeople.do?id=" + row.id).then((res) => {
                        if (res.data.flag) {
                            this.$message({
                                message: res.data.message,
                                type: 'success'
                            })
                        } else {
                            this.$message.error(res.data.message)
                        }
                    }).finally(() => {
                        this.findPage();
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            }
        }
    })
</script>
</html>
